﻿
String.prototype.padRight = function (s, l) {
    var rtn = this;
    while (rtn.length + s.length < l) {
        rtn += s;
    }
    if (rtn.length < l) {
        rtn += s.substr(0, l - rtn.length);
    }
    return rtn;
};

String.prototype.padLeft = function (s, l) {
    var rtn = this;
    while (rtn.length + s.length < l) {
        rtn = s + rtn;
    }
    if (rtn.length < l) {
        rtn = s.substr(0, l - rtn.length) + rtn;
    }
    return rtn;
};

Date.prototype.getStdFormat = function () {
    return (this.getYear() + 1900) + '-' + 
    (1 + this.getMonth()).toString().padLeft('0', 2) + '-' +
    this.getDate().toString().toString().padLeft('0', 2) + ' ' +
    this.getHours().toString().padLeft('0', 2) + ':' +
    this.getMinutes().toString().padLeft('0', 2) + ':' +
    this.getSeconds().toString().padLeft('0', 2);
};

Date.prototype.getUnixStamp = function () {
    return Math.floor(this.getTime() / 1000);
};
